package webshop.data;
import javax.persistence.*;
import java.io.Serializable;
    /* @ManyToOne
    @JoinColumns({
        @JoinColumn(name="product_id", referencedColumnName="product_id"),
        @JoinColumn(name="order_id", referencedColumnName="order_id")
    })*/
    ////////////////// NOT SURE HOW TO DECLEAR THIS: 2x foreign key's create a
    ////////////////// COMPOSITE PRIMARY KEY.
     /*  @Entity
    @Table(name="VCUST")
    @DiscriminatorValue("VCUST")
    @PrimaryKeyJoinColumns({
        @PrimaryKeyJoinColumn(name="CUST_ID",
            referencedColumnName="ID"),
        @PrimaryKeyJoinColumn(name="CUST_TYPE",
            referencedColumnName="TYPE")
    })
    public class ValuedCustomer extends Customer { ... }
    */
/*@Entity
@Table(name="is202_orderline")
@NamedQuery(name="Orderline.findById",query="select o from Orderline o where o.orderId like :orderId")*/
@Entity
@Table(name="is202_orderline")
/*@SecondaryTables({
    @SecondaryTable(name="is202_order",
        pkJoinColumns=@PrimaryKeyJoinColumn(name="order_id")),
    @SecondaryTable(name="is202_product",
        pkJoinColumns=@PrimaryKeyJoinColumn(name="product_id"))
})
 * */
//@IdClass(webshop.data.OrderlineId.class)
public class Orderline implements Serializable {
    // Define Variables.
    
    @EmbeddedId
    @Column(name="id")
    @ManyToOne
    protected OrderlineId orderlineId;

    @ManyToOne(optional=false)
    @JoinColumn(name="id", referencedColumnName="id")
    private ShoppingBasket shoppingBasket;
    /*@Id
    @ManyToOne
    @JoinColumn(name="product_id")
    private long productId;

    @Id 
    @ManyToOne
    @JoinColumn(name="shoppingbasket_id")
    private long basketId;
     * */
    // Or?
    /*@Id @ManyToOne @Column(name="order") private Product product;
    @Id @ManyToOne @Column(name="order") private Order order;*/

    @Column(name="quantity", nullable=false)
    private int quantity;

    // Constructors.
    public Orderline(){
    }

    public Orderline(int quantity){
        this.setQuantity(quantity);
    }

    // Getters and Setters.
   /*
    public long getProductId() {
        return productId;
    }

    public void setProductId(long productId) {
        this.productId = productId;
    }

    public long getBasketId() {
        return basketId;
    }

    public void setOrderId(long basketId) {
        this.basketId = basketId;
    }
    * */

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }
    
}
